#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <queue>
using namespace std;
class Solution {
public:
    vector<int> deckRevealedIncreasing(vector<int>& deck) {
        int n = deck.size(), idx = 0;
        map<int, int> map;
        deque<int> d;
        for (int x : deck) d.push_back(x);
        while (!d.empty()) {
            map[d.front()] = idx++;
            d.pop_front();
            if (!d.empty()) {
                d.push_back(d.front());
                d.pop_front();
            }
        }
        vector<int> ans(n);
        vector<int> temp = deck;
        sort(temp.begin(), temp.end());
        for (int i = 0; i < n; i++) ans[i] = temp[map[deck[i]]];
        return ans;
    }
};
int main()
{
	return 0;
}